<template>
  <div ref="qrcode"></div>
</template>
<script>
import * as QRCode from 'easyqrcodejs'
import logoUrl from '../../public/ic_launcher.png'
export default {
  name: 'Qrcode',
  props: {
    text: {
      type: String,
      default: ''
    },
    size: {
      type: Number,
      default: 100
    }
  },
  data: function() {
    return {
      qrcode: null
    }
  },
  watch: {
    text: function() {
      this.qrcode.makeCode(this.text)
    }
  },
  mounted: function() {
    const options = {
      text: this.text,
      correctLevel: QRCode.CorrectLevel.H,
      logo: logoUrl
    }
    this.qrcode = new QRCode(this.$refs.qrcode, options)
  }
}
</script>
<style scoped>
</style>
